<!DOCTYPE html>
<html lang="en" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/custom.form.css">
</head>
<body>
<div class="case_table_div">
    <table class="layui-hide" id="case_table" lay-filter="case_table"></table>
</div>
</body>
<script type="text/html" id="tool">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" >清除数据</a>
</script>

<script src="/layui/layui.all.js"></script>
<script src="/js/core.util.js"></script>
<script>
    //获取token
    var token = CoreUtil.getData("access_token");
    //地址栏转义token中的#号
    var tokenQuery = token.replace("#", "%23");
    var tableIns1;
    var tableAjxx;
    var table = layui.table;
    var form = layui.form;
    var layer = layui.layer;
    var upload = layui.upload;
    var $ = jQuery = layui.jquery;
    var laydate = layui.laydate;
    var tree = layui.tree;
    var startTime = null;
    var endTime = null;
    layui.config({
        base: '/'
    }).extend({
        eleTree: 'layui-ext/eleTree/eleTree'
    }).use(['table', 'laypage', 'layer', 'laydate', 'tree', 'eleTree','upload'], function () {
        // 定义固定的数据
        var data = [
            {id: 1, name: '积案案件状态变化数据'},
            {id: 2, name: '积案预计清理时间数据'},
        ];
        tableIns1 = table.render({
            elem: '#case_table'
            ,data:data
            , cols: [
                [
                    {field: 'id', hide:true},
                    {field: 'name', title: '事项名称', width: 400},
                    {title: '操作', width: 250, toolbar: '#tool'}
                ]
            ]
            , toolbar: '#toolbar'
        });

        table.on('tool(case_table)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'del':
                    tipDialog(data.id);
                    break;
            }
        });
        var tipDialog = function (id) {
            let contentText='';
            if(id === 1){
                contentText = "确定要清除积案案件状态变化数据吗？";
            }else if (id === 2)
            {
                contentText = "确定要清除积案预计清理时间数据吗？";
            }
            layer.open({
                content: contentText,
                yes: function (index, layero) {
                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                    CoreUtil.sendPost("/attention/jasjqc/deleted/" + id, null, function (res) {
                        layer.msg(res.msg);
                        search();
                    });
                }
            });
        }
    });


    //执行查询
    function pldel() {
        var caseId =  $("#zxajId").val();
        var checkStatus = table.checkStatus('case_ajxx_table'),
            data = checkStatus.data,
            ajxxIds = "";
        if (data.length > 0) {
            for (var i in data) {
                ajxxIds += data[i].id + ",";
            }
            console.log(ajxxIds);//打印获取到选中的id，用，分割
            layer.open({
                content: '确定要删除选择的案件吗？',
                yes: function (index, layero) {
                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                    CoreUtil.sendPost("/attention/specialCaseManagement/pldeletedajxx/"+ ajxxIds,null, function (res) {
                        layer.msg(res.msg);
                        searchAjxx(caseId);
                    });
                }
            });
        } else {
            layer.msg("请选择需要删除的案件");  //如果未选择数据，则提示。
        }
    };
</script>
</html>